<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="display" uri="/WEB-INF/tags/displaytag-12.tld"%>
<%@page import="com.opensymphony.module.sitemesh.Page"%>
<html>
<head>
<meta name="tab" content="students" />
<meta name="leftbar-link" content="add-to-batch"/>
<meta name="decorator" content="DefaultLayout"/>
</head>
<body>
<script LANGUAGE="JAVASCRIPT">

	function doSubmit()
	{
 		if(validateForm())
 		{
 		  document.getElementById('batchForm').action="addStudentToBatch.action";
		  document.getElementById('batchForm').submit();
 		}else{
 		  alert('Please select a Batch from List'); 
 		  return false;		
 		}
	}
	
		function validateForm(){
	    
	     var flag = false;
		 var radioObj = document.forms[0].batchId;
		 var radioLength = radioObj.length;
			if(radioLength == null) {
				radioLength = 1;
				if(radioObj.checked){
					flag = true;
				}
			} else {
			//alert ("Length " +radioLength);
	
		 for(var i = 0; i < radioLength; i++) {
			alert(radioObj[i].checked)
			 if(radioObj[i].checked) {
				 flag = true;
				 //alert("valid successful");
				 break;

			 }
		  }
}
	  return flag;
	}

</script>
<span id="pageHeading">Select Batch<hr/></span>

<s:form  name="batchForm" action="/addStudentToBatch.action" method="post">
<table width="100%" border="1">
  <tr>
  <tr>
      <td width = "15%">Selected Student Ids </td>
      <td> <s:property value="selectedStudentIds"/> </td>
  </tr>
</table>
  <display:table name="batchList" id="batch" class="dataTable" requestURI=""
      cellspacing="0"  sort="list"  pagesize="10" export="true" 
      decorator="org.displaytag.decorator.TotalTableDecorator" >
      <display:column title="Batch Id" class="#externalLinks" media="html">
        <a href="#">
         ${batch.id}
        </a> 
      </display:column>
      <display:column title="Level" property="level" sortable="true"/>
      <display:column title="CI Name" property="ciName" sortable="true"/>
      <display:column title="Start Date" property="startDateStr" sortable="true"/>
      <display:column title="End Date" property="endDateStr" sortable="true"/>
      <display:column title="Remarks" property="remarks" sortable="true"/>
      <display:column>
		<input type="radio" id="batchId" name="batchId" value='${batch.id}'/>
      </display:column>
</display:table>
<table border="0" width="100%">
 <tr>
    <td align="center">
	  <A class="orange" style="cursor:pointer;" onclick="javascript:doSubmit();">
	     Done
      </A>
    </td>
 </tr>
</table>
<s:hidden name="selectedStudentIds" />
</s:form>
</body>
</html>
